using System.Collections.Generic;
using System.Linq;
using System.Windows;
using PrismNavigationFramework.MVVM;

namespace PrismNavigation.App.Infrastructure
{
    public class ParametersAwareViewModel<TView> : ViewModel<TView> where TView : class
    {
        public override void Initialize(ViewInitializationData initializationData)
        {
            this.Parameters = initializationData.Parameters;
        }

        public Visibility WeHaveParameters
        {
            get
            {
                if (Parameters == null)
                {
                    return Visibility.Collapsed;
                }

                return Parameters.Keys.Any() ? Visibility.Visible : Visibility.Collapsed;
            }

        }

        private Dictionary<string, string> _parameters;
        public Dictionary<string, string> Parameters
        {
            get { return _parameters; }
            set
            {
                _parameters = value;
                this.OnPropertyChanged("Parameters");
                this.OnPropertyChanged("WeHaveParameters");
            }
        }        
    }
}